home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / Forwhile.pxl < prev    next >
Text File  |  2000-12-23  |  4KB  |  193 lines

  1. Initialize:
  2.     WinGetActive(Win$)
  3.     UseCoordinates(PIXEL)
  4.     UseBackGround(TRANSPARENT,192,192,192)
  5.     DrawBackGround
  6.     WaitInput(100)  {let NT and 95 catch up}
  7.     InfoMenu(REMOVE)
  8.     SetMenu()
  9.     WinLocate(Win$,250,10,620,240,Res) 
  10.     Title$ = "For and While Loops"
  11.     WinTitle(Win$, Title$)
  12.     {WinShow(Title$,NOTOPMOST,Res)}
  13.     DirGet(SourceDir$)
  14.  
  15.  
  16.     SetMenu("E&xit!",Leave,
  17.         ENDPOPUP,
  18.         "&FOR Loops",IGNORE,
  19.         "&Programmed FOR",ProgramFor,
  20.         "&Structured FOR",ConstructFor,
  21.         ENDPOPUP,
  22.         "&WHILE Loops",IGNORE,
  23.         "&Programmed WHILE",ProgramWhile,
  24.         "&Structured WHILE",ConstructWhile,
  25.         ENDPOPUP,
  26.         "For-&If-While",ForIfWhile,
  27.         ENDPOPUP,
  28.         "&Help",IGNORE,
  29.         "&Concept",Concept,
  30.         "&View Source",ViewSource,
  31.         "&About",About,
  32.         ENDPOPUP)
  33.         
  34. Wait_for_Input:
  35.     WaitInput()
  36.  
  37.  
  38. Leave:
  39.     End
  40.  
  41. Concept:
  42.     MessageBox(OK,1,INFORMATION,
  43. "This sample program demonstrates the two 
  44. available methods of programming FOR and 
  45. WHILE loops, using firstly:
  46.     Labels and 'Goto' statements;
  47. and secondly:
  48.     Structured FOR and WHILE
  49.     Keywords.
  50.  
  51. Look in the sources to see the differences.",
  52.     "Structured Program controls",Res)
  53.     Goto Wait_for_Input
  54.  
  55. ViewSource:
  56.     PXLFile$ = SourceDir$ + "\forwhile.pxl"
  57.     CmdLine$ = "NotePad " + PXLFile$
  58.     Run(CmdLine$)
  59.     Goto Wait_for_Input
  60.  
  61.  
  62. About:
  63.     AboutUser("Structured Program Loops with PiXCL 4.2",
  64. "FOR - NEXT and WHILE - ENDWHILE structures in PiXCL",
  65. "Sample PiXCL 4.2 program showing variety of built in icons drawn in the client area, depending on the loop parameters")
  66.     Goto Wait_for_Input
  67.  
  68.  
  69. ProgramFor:
  70.     Count = 0
  71.     DrawBackGround
  72. For_Loop:
  73.     DrawIcon( 1,1,0,0,ICON01)
  74.     DrawIcon(41,1,0,0,ICON02)
  75.     DrawIcon(81,1,0,0,ICON03)
  76.     Count++
  77.     Break
  78.     If Count <= 200 Then Goto For_Loop
  79.     DrawText(10,50,"Programmed For Loop complete")
  80.     Goto Wait_for_Input
  81.  
  82.  
  83. ConstructFor:
  84.     DrawBackGround
  85.     For Count = 0 To 10 By 2
  86.         DrawIcon( 1,1,0,0,ICON01)
  87.         For InnerCount = 0 To 6 By 2
  88.         If InnerCount = 6 Then DebugMsgBox("Inner For Loop")    
  89.         Next
  90.         DrawIcon(41,1,0,0,ICON02)
  91.         If Count > 40 Then DrawIcon( 1,1,64,64,ICON11) Break
  92.         DrawIcon(81,1,0,0,ICON03)
  93.     Next
  94.         DrawNumber(150,20,Count)
  95.  
  96.     DrawText(10,80,"Structured For Loop complete.")
  97.     Goto Wait_for_Input
  98.  
  99. ProgramWhile:
  100.     Count = 0
  101.     DrawBackGround
  102. While_Loop:
  103.     If Count > 100 Then Goto While_End
  104.         DrawIcon( 1,1,0,0,ICON04)
  105.         DrawIcon(41,1,0,0,ICON05)
  106.         DrawIcon(81,1,0,0,ICON06)
  107.         Count++
  108.     Goto While_Loop
  109. While_End:
  110.     DrawText(10,50,"Programmed While Loop complete.")
  111.     Goto Wait_for_Input
  112.  
  113. ConstructWhile:
  114.     Count = 0
  115.     DrawBackGround
  116.     While Count <= 5
  117.         DrawIcon( 1,1,0,0,ICON04)
  118.         DrawIcon(41,1,0,0,ICON05)
  119.         DrawIcon(81,1,0,0,ICON06)
  120.         If Count > 3 Then DrawIcon( 1,41,0,0,ICON11) Break
  121.         Count++
  122.     EndWhile
  123.     DrawNumber(150,20,Count)    
  124.  
  125.     Count$ = "A"  Count = 0
  126.     Count1$ = "C"  Count1= 0
  127.     Count2$ = "E"
  128.     While Count$ = "A"
  129.         DrawIcon( 1,41,0,0,ICON07)
  130.         DrawIcon(41,41,0,0,ICON08)
  131.         DrawIcon(81,41,0,0,ICON09)
  132.  
  133.         While Count1$ = "C"
  134.         Count1++
  135.         If Count1 > 2 Then Count1$ = "D"
  136.         DebugMsgBox("Inside inner loop#1")    
  137.  
  138.             While Count2$ = "E"
  139.         Count2++
  140.         If Count2 > 2 Then Count2$ = "F"
  141.         DebugMsgBox("Inside inner loop#2")    
  142.             EndWhile
  143.  
  144.  
  145.  
  146.         EndWhile
  147.  
  148.         If Count > 3 Then Count$ = "B"
  149.         Count++
  150.     EndWhile
  151.     DrawNumber(150,50,Count)    
  152.     DrawText(10,80,"Outer Structured While Loop complete.")
  153.  
  154.     Goto Wait_for_Input
  155.  
  156. ForIfWhile:
  157.     DrawBackground
  158.     X = 1  Y = 1
  159.     For A = 0 To 10
  160.        C = A
  161.         While C < 10
  162.             If A < 5 
  163.             DrawIcon(1,1,0,0,ICON01)
  164.             Else
  165.            While X < 10
  166.                 DrawIcon(X,Y,0,0,ICON10)
  167.                 X +=2   Y += 2
  168.             EndWhile
  169.         Endif
  170.             C++
  171.         EndWhile
  172.     Next
  173.  
  174.     For A = 0 To 10
  175.        C = A
  176.         If A < 5 
  177.             DrawIcon(1,1,0,0,ICON01)
  178.         Else
  179.            While X < 10
  180.                 DrawIcon(X,Y,0,0,ICON10)
  181.                 X +=2   Y += 2
  182.             EndWhile
  183.         Endif
  184.         C++
  185.     Next
  186.  
  187.  
  188.     Goto Wait_for_Input
  189.  
  190.  
  191.  
  192.  
  193.